/**
 * Copyright (C) 2009-2012, KingHool.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses.
 */
package com.kinghool.smodel.def;

import java.util.Collections;
import java.util.List;

import com.kinghool.ebos.commons.utils.Assert;
import com.kinghool.ebos.commons.utils.Utils;

/**
 * 
 * @Author Allen Deng(dengtailin@gmail.com) 
 */
public class StaticValueProvider implements IValueProvider {
    private List<Object> values = Utils.newList(5);
    private boolean exclusive = true;
    
    private StaticValueProvider() {}
   
	public static StaticValueProvider newStaticValueProvider(boolean exclusive, Object... initStrs) {
		StaticValueProvider provider = new StaticValueProvider();
		if (! Assert.isNullOrEmpty(initStrs)) {
			for (Object str : initStrs) {
				provider.values.add(str);
			}
		}
		provider.exclusive = exclusive;
		return provider;
	}
	
	public static StaticValueProvider newStaticValueProvider(boolean exclusive, List<Object> initStrs) {
		return newStaticValueProvider(exclusive, initStrs.toArray(new Object[0]));
	}
	
	public static StaticValueProvider newStaticValueProvider(List<Object> initStrs) {
		return newStaticValueProvider(true, initStrs.toArray(new Object[0]));
	}
	
	public static StaticValueProvider newStaticValueProvider(Object... initStrs) {
		return newStaticValueProvider(true, initStrs);
	}
	
	public List<Object> getValues() { 
		return Collections.unmodifiableList(values);
	}
	
	public List<Object> getValues(Object ctx) {
		return getValues();
	}
	
	public boolean isExclusive() {
		return exclusive;
	}
}
